package bean;

import java.util.HashMap;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class Locale extends LinkItem {
	public static final String TABLE_NAME = "locali";
	
	////////////////////////////////////////////////////////////
	//Bean fields
	private String id;
	private String name;
	private String type;
	private String desc;
	private String address;
	private String image;
	////////////////////////////////////////////////////////////

	////////////////////////////////////////////////////////////
	//Column names
	public static final String ID_COL = "idlocali";
	public static final String NAME_COL = "name";
	public static final String TYPE_COL = "type";
	public static final String DESC_COL = "description";
	public static final String ADDRESS_COL = "address";
	public static final String IMAGE_COL = "image";
	////////////////////////////////////////////////////////////

	////////////////////////////////////////////////////////////
	//Constructor for html form
	public Locale() {
	}
	////////////////////////////////////////////////////////////

	/**
	 * Get the info from a table ROW by column name
	 * @param line
	 */
	public Locale(HashMap<String, String> line) {
		id = line.get(ID_COL);
		name = line.get(NAME_COL);
		type = line.get(TYPE_COL);
		desc = line.get(DESC_COL);
		address = line.get(ADDRESS_COL);
		image = line.get(IMAGE_COL);
	}

	////////////////////////////////////////////////////////////
	//Getters and setters
	public String getName() {
		return name;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getImage() {
		return image;
	}
	public void setImage(String image) {
		this.image = image;
	}
	////////////////////////////////////////////////////////////

	@Override
	public String toString() {
		return getId() + "|" + getName() + "|" + getType();
	}
	
	@Override
	public boolean equals(Object obj) {
		Locale l = (Locale) obj;
		System.out.println(l.getName() + " == " + this.getName());
		return l.getName().equals(this.getName());
	}
}
